#!/usr/bin/env python
# -*-coding:utf-8-*-
# File    : liyuqi.py

import copy
import random

mydict = {
  "name": "Tom",
  "age": "18",
  "sex": 1,
  "city": "深圳",
  "province": "广东",
  "ext": {
    "type": "dynamic",
    "inner_hits": {},
    "score_mode": "avg",
    "min_children": 0,
    "max_children": 25555,
    "ignore_unmapped": False,
    "boost": 1
  }
}

users = []
names = set()
for _ in range(10):
    #深拷贝模板
    user = copy.deepcopy(mydict)
    # user = copy.copy(mydict)

    #生成name，并保证唯一
    name = ''.join(random.sample('abcdefghijklmnopqrstuvwxyz',random.randint(3, 5)))
    while name in names:
        name = random.sample('abcdefghijklmnopqrstuvwxyz', random.randint(3, 5))
    names.add(name)
    user["name"] = name

    # 生成age
    user["age"] = random.randint(11, 59)

    # 生成sex
    user["sex"] = random.randint(0, 2)

    user["ext"]["boost"] = random.randint(0, 3)

    users.append(user)

#打印结果
for u in users:
    print(u)